$(function(){
	var arr = new Array();//存放视频路径
	//url中的id截取
	var urlId = window.location+"";
	var index = urlId.indexOf("?");
	if(index>0){
		urlId = urlId.substring(index+1);
	}else{
		urlId = null;
	}
	var playType ="html";
	$.ax(
		"cr/findById",
		"id="+urlId,
		null,
		"get",
		"json",
		function(data){
			if(data.messageCode===200){
					var obj = data.sysdata.carouselResources;
					var str = "";
					if(obj.content!=undefined){
							str = "<p>"+obj.content+"</p>";
					}
			
					var play = obj.video;
					
					var index = play.toString().lastIndexOf(".");
					var format = play.substring(index+1);
					if(format=="flv"){
						playType ="flash";
					}
					if(format=="mp4"){
						format = "m4v";
					}else if(format=="webm"){
						format = "webmv";
					}
	
					var vObj = new Object();
					vObj[format] = play;
					arr[0] = vObj;
					console.log(vObj);
					console.log(arr);
					
				}
				$(".box-p").html(str);
				videofun();
		},
		function(){
			alert("error");
		}
	);
	//对视频的播放
	function videofun(){
		console.log(arr);
		var myPlaylist = new jPlayerPlaylist({
			jPlayer: "#jquery_jplayer_N",
			cssSelectorAncestor: "#jp_container_N"
		},arr, {
			playlistOptions: {
				autoPlay: true,
				enableRemoveControls: true
			},
			swfPath: "file/jquery.jplayer.swf",
			supplied: "webmv, ogv, m4v, oga, mp3,flv",
			solution: playType,
			useStateClassSkin: true,
			autoBlur: false,
			smoothPlayBar: true,
			keyEnabled: true,
			audioFullScreen: true,
			size:{
				width:"100%",
//				height:"100%",
				cssClass:""
			},
			loop:true,
			repeat:function(event) {
			  if(event.jPlayer.options.loop) {
			    $(this).unbind(".jPlayerRepeat").bind($.jPlayer.event.ended + ".jPlayer.jPlayerRepeat", function() {
			      $(this).jPlayer("play");
			    });
			  } else {
			    $(this).unbind(".jPlayerRepeat");
			  }
			}
		});
	}
})
